<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="costCode-form">
                <div class="select-list">
                    <ul>
                        <li>
                            编码编号：<input type="text" name="codeNum"/>
                        </li>
                        <li>
                            编码名称：<input type="text" name="codeName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="add()">
                <i class="fa fa-plus"></i> 新增根目录
            </a>
            <a class="btn btn-info" id="expandAllBtn">
                <i class="fa fa-exchange"></i> 展开/折叠
            </a>
            <!--内部导入不显示-->
            <!--<a class="btn btn-info" onclick="$.table.importExcel()">-->
            <!--<i class="fa fa-upload"></i> 导入-->
            <!--</a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-tree-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "costCode";

    $(function () {
        var options = {
            code: "codeId",
            parentCode: "parentId",
            uniqueId: "codeId",
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            importUrl: prefix + "/importData",
            modalName: "项目",
            expandAll: false,//是否全部展示
            expandFirst: false,//不展开二级
            striped: true,//是否显示行间色
            columns: [{
                field: 'selectItem',
                radio: true
            },
                {
                    field: 'codeNum',
                    title: '编码编号',
                    align: "left"
                },
                {
                    field: 'codeName',
                    title: '编码名称',
                    align: "left"
                },
                {
                    field: 'codeFeature',
                    title: '特征',
                    align: "left",
                },
                {
                    field: 'codeUnitName',
                    title: '单位',
                    align: "left"
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.codeId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info  btn-xs" href="javascript:void(0)" onclick="add(\'' + row.codeId + '\')"><i class="fa fa-plus"></i>新建下级</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.codeId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.treeTable.init(options);
    });

    function add(codeId) {
        $.operate.add((typeof(codeId) == "undefined" ? 0 : codeId));
    }
</script>
</body>
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>